<template>
   <div >
     <ul>
       <li v-for="(val,index) in arr" :key="index" > {{ val }} </li>
     </ul>
     <hr>
     <button @click="sortBtn" >排序</button>
     <button @click="reBtn" >翻转</button>
     <button @click="jBtn" >截取前3个</button>
     <button @click="upBtn" >修改下标为2的值</button>
   </div>
</template>

<script>
export default {
  data() {
       return {
         arr : [5,103,2,9,1]
       };
   },
//方法
methods: {
  sortBtn(){
    this.arr.sort((a,b) => a - b);
  },
  reBtn(){
    this.arr.reverse()
  },
  jBtn(){
    this.arr.slice(0,3);
  },
  upBtn(){
    this.$set(this.arr,2,500)
  }
},
//过滤器
filters: {},
// 计算属性
computed: {},
// 侦听器
watch: {},
}
</script>

<style scoped>
</style>
